/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.mrp.ppm.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import merlion.scm.lcm.entity.DeliveryOrder;

/**
 *
 * @author Zhang Ying
 */
@Entity
public class Reservation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    private Timestamp reservationTime;
    private Long quantity;
    
    
//    @ManyToOne(targetEntity = BackOrder.class, cascade = {CascadeType.MERGE}, fetch = FetchType.EAGER)
//    private BackOrder backOrder;
    
    @ManyToOne(targetEntity = DeliveryOrder.class, cascade = {CascadeType.MERGE}, fetch = FetchType.EAGER)
    private DeliveryOrder deliveryOrder;
    
    @ManyToOne(targetEntity = DailyPlannedProduction.class, cascade = {CascadeType.MERGE}, fetch = FetchType.EAGER)
    private DailyPlannedProduction dpp;
    
    public Reservation() {
        
    }
    
    public Reservation(Long qty) {
        reservationTime = new Timestamp(System.currentTimeMillis());
        this.quantity = qty;
    }

    public DailyPlannedProduction getDpp() {
        return dpp;
    }

    public void setDpp(DailyPlannedProduction dpp) {
        this.dpp = dpp;
    }


    
    public Long getQuantity() {
        return quantity;
    }

    public void setQuantity(Long quantity) {
        this.quantity = quantity;
    }

    public Timestamp getReservationTime() {
        return reservationTime;
    }

    public void setReservationTime(Timestamp reservationTime) {
        this.reservationTime = reservationTime;
    }

//    public BackOrder getBackOrder() {
//        return backOrder;
//    }
//
//    public void setBackOrder(BackOrder backOrder) {
//        this.backOrder = backOrder;
//    }

    public DeliveryOrder getDeliveryOrder() {
        return deliveryOrder;
    }

    public void setDeliveryOrder(DeliveryOrder deliveryOrder) {
        this.deliveryOrder = deliveryOrder;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Reservation)) {
            return false;
        }
        Reservation other = (Reservation) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.mrp.ppm.entity.Reservation[ id=" + id + " ]";
    }
    
}
